<?php

namespace yii\authclient\clients;

use yii\authclient\OAuth2;

class Weibo extends OAuth2 {

    public $authUrl = 'https://api.weibo.com/oauth2/authorize';
    public $tokenUrl = 'https://api.weibo.com/oauth2/access_token';
    public $apiBaseUrl = 'https://api.weibo.com';

    protected function initUserAttributes() {
        $openid = $this->api('oauth2/get_token_info', 'POST');
        $userAttributes = $this->api("2/users/show.json", 'GET', ['uid' => $openid['uid']]);
        $userAttributes['openid'] = $openid['uid'];
        return $userAttributes;
    }

    protected function defaultName() {
        return 'weibo';
    }

    protected function defaultTitle() {
        return '微博';
    }
}